﻿#include <iostream>
using namespace std;

struct Node 
{
    int data;
    Node* next;
};

int main() 
{
    Node* head = nullptr;
    int num;

    while (cin >> num && num != -1) 
    {
        Node* newNode = new Node();
        newNode->data = num;
        newNode->next = head;
        head = newNode;
    }

    Node* current = head;
    while (current != nullptr) 
    {
        cout << current->data << " ";
        current = current->next;
    }
    cout << endl;

    while (head != nullptr) 
    {
        Node* temp = head;
        head = head->next;
        delete temp;
    }

    return 0;
}




